<template>
  <div class="search-from flex justify-between">
    <el-form :inline="true" :model="searchFrom">
      <!-- 5月16号注释 -->
      <!--  <el-form-item label="诊改级别：" v-if="levelType != level.XX.code">
        <el-input v-model="searchFrom.level" clearable placeholder="诊改级别"></el-input>
      </el-form-item> -->
      <el-form-item label="对象名称：">
        <el-input v-model="searchFrom.rectificationObjectName" clearable placeholder="对象名称"></el-input>
      </el-form-item>
      <!-- 5月16号注释 -->
      <!-- <el-form-item label="责任部门：" v-if="levelType === level.XX.code">
        <el-select v-model="searchFrom.dutyPart" filterable clearable placeholder="请选择责任部门">
          <el-option :label="item.orgName" :value="item.id" v-for="item in organizeArr" :key="item.id"></el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item label="责任部门：">
        <el-select v-model="searchFrom.dutyPart" filterable clearable placeholder="请选择责任部门">
          <el-option :label="item.orgName" :value="item.id" v-for="item in organizeArr" :key="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="年份：">
        <el-select v-model="searchFrom.year" placeholder="年份">
          <el-option v-for="(year,i) in yearArr" :label="year" :value="year" :key="i"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="searchData">查询</el-button>
        <slot name="handle"></slot>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getAllOrganize } from '@/api/systemManage'

export default {
  name: 'index',
  props: {
    levelType: {
      type: [Number, String]
    }
  },
  data () {
    return {
      yearArr: this.$config.yearArr(),
      level: this.$config.level,
      searchFrom: {
        level: '',
        rectificationObjectName: '',
        year: new Date().getFullYear() - 1, // 年度默认为当前年份
        // year: '',
        dutyPart: ''
      },
      // 责任部门
      organizeArr: []
    }
  },
  created () {
    // 除 模板管理、 标准管理 、标准审核 三个模块外其他的均默认选中
    var path = this.$route.path
    if (path.indexOf('standard') !== -1 || path.indexOf('standardManage') !== -1 || path.indexOf('check') !== -1) {
      this.searchFrom.year = ''
    }
    this.$emit('search', this.searchFrom)
    this.getOrganize()
  },
  methods: {
    searchData () {
      this.$emit('search', this.searchFrom)
    },
    // 获取责任部门下拉数据
    getOrganize () {
      getAllOrganize()
        .then(res => {
          this.organizeArr = res || []
        })
        .catch()
    }
  }
}
</script>

<style scoped>
</style>
